package snippet.sqlserver;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class JdbcSQLServerDriverUrlExample {
	public static void main(String[] args)
	  {
	    Connection connection = null;
	    try
	    {
	      // the sql server driver string
	      Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

	      // the sql server url
	      String url = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=qstart";

	      // get the sql server database connection
	      connection = DriverManager.getConnection(url,"tibadmin", "tibadmin");

	      // now do whatever you want to do with the connection
	      // ...
	      System.out.println("connected !");

	    }
	    catch (ClassNotFoundException e)
	    {
	      e.printStackTrace();
	      System.exit(1);
	    }
	    catch (SQLException e)
	    {
	      e.printStackTrace();
	      System.exit(2);
	    }
	  }

}
